/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * NewJFrame.java
 *
 * Created on 21-nov-2009, 20:49:02
 */
package GUI;

import Controlador.Controlador;
import Modelo.Idiomas.LocaleManager;
import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.JOptionPane;

/**
 *
 * @author Fonso
 */
public class GUI_Iconos extends javax.swing.JFrame {

    private static Controlador controlador;

    /** Creates new form NewJFrame */
    public GUI_Iconos() throws Exception {
        initComponents();
        cambioIdioma();
        controlador = InicioAplicacion.getControlador();
        centrarAplicacion();
        setVisible(true);
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        DPPrincipal = new javax.swing.JDesktopPane();
        BSalir = new javax.swing.JButton();
        BAyuda = new javax.swing.JButton();
        BNavegacionGps = new javax.swing.JButton();
        BCalibracion = new javax.swing.JButton();
        BNavegacionNoGps = new javax.swing.JButton();
        BConfiguracion = new javax.swing.JButton();
        LTitulo = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setTitle("Geomantes PC");

        DPPrincipal.setBackground(new java.awt.Color(192, 192, 192));
        DPPrincipal.setName("Geomantes PC"); // NOI18N

        BSalir.setFont(new java.awt.Font("Tahoma", 1, 12));
        BSalir.setForeground(java.awt.Color.darkGray);
        BSalir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Archivos/ImagenesMenu/menuSalir.png"))); // NOI18N
        BSalir.setText("SALIR");
        BSalir.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(102, 153, 255), 3, true));
        BSalir.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        BSalir.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        BSalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BSalirActionPerformed(evt);
            }
        });
        BSalir.setBounds(480, 370, 160, 170);
        DPPrincipal.add(BSalir, javax.swing.JLayeredPane.DEFAULT_LAYER);

        BAyuda.setFont(new java.awt.Font("Tahoma", 1, 12));
        BAyuda.setForeground(java.awt.Color.darkGray);
        BAyuda.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Archivos/ImagenesMenu/menuAyuda.png"))); // NOI18N
        BAyuda.setText("AYUDA");
        BAyuda.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(102, 153, 255), 3, true));
        BAyuda.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        BAyuda.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        BAyuda.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BAyudaActionPerformed(evt);
            }
        });
        BAyuda.setBounds(480, 140, 160, 170);
        DPPrincipal.add(BAyuda, javax.swing.JLayeredPane.DEFAULT_LAYER);

        BNavegacionGps.setFont(new java.awt.Font("Tahoma", 1, 12));
        BNavegacionGps.setForeground(java.awt.Color.darkGray);
        BNavegacionGps.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Archivos/ImagenesMenu/menuNavegacion3.png"))); // NOI18N
        BNavegacionGps.setText("NAVEGACIÓN LIBRE");
        BNavegacionGps.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(102, 153, 255), 3, true));
        BNavegacionGps.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        BNavegacionGps.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        BNavegacionGps.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BNavegacionGpsActionPerformed(evt);
            }
        });
        BNavegacionGps.setBounds(20, 140, 160, 170);
        DPPrincipal.add(BNavegacionGps, javax.swing.JLayeredPane.DEFAULT_LAYER);

        BCalibracion.setFont(new java.awt.Font("Tahoma", 1, 12));
        BCalibracion.setForeground(java.awt.Color.darkGray);
        BCalibracion.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Archivos/ImagenesMenu/menuCalibracion.png"))); // NOI18N
        BCalibracion.setText("CALIBRACIÓN");
        BCalibracion.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(102, 153, 255), 3, true));
        BCalibracion.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        BCalibracion.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        BCalibracion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BCalibracionActionPerformed(evt);
            }
        });
        BCalibracion.setBounds(20, 370, 160, 170);
        DPPrincipal.add(BCalibracion, javax.swing.JLayeredPane.DEFAULT_LAYER);

        BNavegacionNoGps.setFont(new java.awt.Font("Tahoma", 1, 12));
        BNavegacionNoGps.setForeground(java.awt.Color.darkGray);
        BNavegacionNoGps.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Archivos/ImagenesMenu/menuPrevisualizar.png"))); // NOI18N
        BNavegacionNoGps.setText("EDITAR MAPAS");
        BNavegacionNoGps.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(102, 153, 255), 3, true));
        BNavegacionNoGps.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        BNavegacionNoGps.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        BNavegacionNoGps.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BNavegacionNoGpsActionPerformed(evt);
            }
        });
        BNavegacionNoGps.setBounds(250, 140, 160, 170);
        DPPrincipal.add(BNavegacionNoGps, javax.swing.JLayeredPane.DEFAULT_LAYER);

        BConfiguracion.setFont(new java.awt.Font("Tahoma", 1, 12));
        BConfiguracion.setForeground(java.awt.Color.darkGray);
        BConfiguracion.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Archivos/ImagenesMenu/menuConfiguracion2.png"))); // NOI18N
        BConfiguracion.setText("CONFIGURACIÓN");
        BConfiguracion.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(102, 153, 255), 3, true));
        BConfiguracion.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        BConfiguracion.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        BConfiguracion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BConfiguracionActionPerformed(evt);
            }
        });
        BConfiguracion.setBounds(250, 370, 160, 170);
        DPPrincipal.add(BConfiguracion, javax.swing.JLayeredPane.DEFAULT_LAYER);

        LTitulo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Archivos/ImagenesMenu/menuTitulo.png"))); // NOI18N
        LTitulo.setBounds(120, 20, 440, 90);
        DPPrincipal.add(LTitulo, javax.swing.JLayeredPane.DEFAULT_LAYER);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(DPPrincipal, javax.swing.GroupLayout.DEFAULT_SIZE, 668, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(DPPrincipal, javax.swing.GroupLayout.DEFAULT_SIZE, 588, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void BSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BSalirActionPerformed
        dispose();
    }//GEN-LAST:event_BSalirActionPerformed

    private void BAyudaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BAyudaActionPerformed
        try {
            String path = getClass().getResource("/Archivos/Ayuda/AyudaGeomantes.pdf").toString();
            Runtime.getRuntime().exec ("rundll32 SHELL32.DLL,ShellExec_RunDLL "+path);
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(
                    null, "Archivo de ayuda no encontrado","Error",JOptionPane.ERROR_MESSAGE);
        }
        setVisible(true);
    }//GEN-LAST:event_BAyudaActionPerformed

    private void BNavegacionGpsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BNavegacionGpsActionPerformed
        new GUI_NavegarGPS(this);
        setVisible(true);
    }//GEN-LAST:event_BNavegacionGpsActionPerformed

    private void BCalibracionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BCalibracionActionPerformed
        new GUI_Calibracion(this);
        this.setVisible(true);
    }//GEN-LAST:event_BCalibracionActionPerformed

    private void BNavegacionNoGpsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BNavegacionNoGpsActionPerformed
        new GUI_Navegar(this);
        setVisible(true);
    }//GEN-LAST:event_BNavegacionNoGpsActionPerformed

    private void BConfiguracionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BConfiguracionActionPerformed
        GUI_Configuracion c = new GUI_Configuracion(this);
        cambioIdioma();
        controlador.setModoMapas(c.getModoMapas());
        controlador.setPuertoSerie(c.getPuertoSerie());
        controlador.setIdioma(c.getIdioma());
        controlador.setCuentaGoogle(c.getCuentaGoogle());
    }//GEN-LAST:event_BConfiguracionActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton BAyuda;
    private javax.swing.JButton BCalibracion;
    private javax.swing.JButton BConfiguracion;
    private javax.swing.JButton BNavegacionGps;
    private javax.swing.JButton BNavegacionNoGps;
    private javax.swing.JButton BSalir;
    private javax.swing.JDesktopPane DPPrincipal;
    private javax.swing.JLabel LTitulo;
    // End of variables declaration//GEN-END:variables

    private void centrarAplicacion() {
        int width = this.getWidth();
        int height = this.getHeight();
        Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
        int x = (screen.width - width) / 2;
        int y = (screen.height - height) / 2;
        setBounds(x, y, width, height);
    }

    private void cambioIdioma() {
        this.BSalir.setText(LocaleManager.getMessage("menuSalir"));
        this.BConfiguracion.setText(LocaleManager.getMessage("menuConfiguracion"));
        this.BNavegacionGps.setText(LocaleManager.getMessage("menuNavGps"));
        this.BNavegacionNoGps.setText(LocaleManager.getMessage("menuNavNoGps"));
        this.BAyuda.setText(LocaleManager.getMessage("menuAyuda"));
        this.BCalibracion.setText(LocaleManager.getMessage("menuCalibracion"));
    }
}
